package edu.cuny.baruch.cis9590.library.database;

import java.util.List;

import edu.cuny.baruch.cis9590.library.entities.Borrow;

public final class BorrowDAO extends LibraryDAO<Borrow> {

	@Override
	protected Class<Borrow> getEntityClass() {
		return Borrow.class;
	}
	
	public Borrow getByBookId(int bookId) {
	    List<Borrow> borrows = query("from Borrow where bookId = " + bookId);
        if (borrows.size() != 1) {
            return null;
        }
        return borrows.get(0);
	}
}
